<block name="body">

    <script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
    
    <div class="tab-wrap">
             <ul class="tab-nav nav">

            <li class="current"><a href="{:U('Admin/Addons/adminList',array('name'=>'ImportData'))}">WordPress导入</a></li>
        </ul>
        <div class="tab-content">
        
        <!-- 标题栏 -->
    <div class="main-title cf">
        <h2>导入博客文章</h2>
    </div>

    <!-- 修改密码表单 -->
    <form action="{:addons_url('ImportData://Import/start')}" method="post" id="import" class="form-horizontal"
          enctype="multipart/form-data">
        <div class="form-item cf">
            <label class="item-label">上传文件<span class="check-tips">（暂时只支持WordPress,请在自己的WP博客后台中导出正确格式的文章XML文件，否则无效）</span></label>

            <div class="controls">
                <input type="file" class="text input-large" id="wpxr_file">
                <input type="hidden" name="wpxr">

                <div id="fileMsg">

                </div>
            </div>
        </div>
        <div class="form-item cf">
            <label class="item-label">导入详情<span class="check-tips">（导入的状态详细信息）</span></label>

            <div class="controls">
                <div class="textarea input-large" style="width:590px;height:300px;overflow-x:auto;white-space:nowrap;">
                    <div id="show-list" ></div>
                </div>
            </div>
            <script type="text/javascript">
                var list = document.getElementById('show-list');
                function showmsg(msg, classname) {
                    var li = document.createElement('p');
                    li.innerHTML = msg;
                    classname && li.setAttribute('class', classname);
                    list.appendChild(li);
                    document.scrollTop += 30;
                }

                function importEnd(msg){
                    $('.ajax-post-file').attr('disabled',"disabled").html('导入完成');
                    $('#wpxr_file').attr('disabled',"disabled");
                    showmsg(msg);
                }
            </script>
        </div>
        <input type="hidden" name="id" value="{$data.id}">
        <button type="submit" class="btn submit-btn ajax-post-file" target-form="form-horizontal">导 入</button>
        <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
    </form>
    <script type="text/javascript">

        $('.ajax-post-file').click(function(){
            var url = $('#import').attr('action');
            var query = $('#import').serialize();
            $.post(url,query).success(function(data){
                    eval(data);
            });
            return false;
        })

        /* 初始化上传插件 */
        $("#wpxr_file").uploadify({
            "height": 30,
            "swf": "__STATIC__/uploadify/uploadify.swf",
            "fileObjName": "download",
            "buttonText": "上传XML文件",
            "uploader": "{:U('File/upload',array('session_id'=>session_id()))}",
            "width": 120,
            'removeTimeout': 1,
            "fileExt": "*.xml,*.xmls",
            "onUploadSuccess": uploadFile,
            'onFallback': function () {
                alert('未检测到兼容版本的Flash.');
            }
        });
        function uploadFile(file, data) {
            var data = $.parseJSON(data);
            if (data.status) {
                $("input[name='wpxr']").val(data.data);
                $("#fileMsg").html(
                        '<div class="upload-pre-file" style="width:350px;"><span class="upload_icon_all"></span>' + data.info + '</div>'
                );
            } else {
                updateAlert(data.info);
            }
        }

    </script>
    
    </div>
    </div>
</block>